import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {RegisterComponent} from '../register/register.component';

@Injectable()
export class GetInfoService {

  constructor(private http: HttpClient) { }
  // 发起请求 返回数据库返回的数据
  getInfo (success: Function) {
    this.http.get('/api/getInfo').subscribe((data) => {
      success && success(data);
    });
  }
  // 新鲜水果
  // outfruits: Array<Pro>;
  getOutfruits (success: Function) {
    this.http.get('/api/outfruits').subscribe((data) => {
      success && success(data);
    });
  }
  // // 蔬菜净菜
  // outgreens: Array<Pro>;
  getOutgreens (success: Function) {
    this.http.get('/api/outgreens').subscribe((data) => {
      success && success(data);
    });
  }
  // // 肉类家禽
  // outmeat: Array<Pro>;
  getOutmeat (success: Function) {
    this.http.get('/api/outmeat').subscribe((data) => {
      success && success(data);
    });
  }
  // // 海鲜水产
  // outseafood: Array<Pro>;
  getOutseafood (success: Function) {
    this.http.get('/api/outseafood').subscribe((data) => {
      success && success(data);
    });
  }
  // // 粮油副食
  // outoils: Array<Pro>;
  getOutoils (success: Function) {
    this.http.get('/api/outoils').subscribe((data) => {
      success && success(data);
    });
  }
  // // 零食酒水
  // outsnack: Array<Pro>;
  getOutsnack (success: Function) {
    this.http.get('/api/outsnack').subscribe((data) => {
      success && success(data);
    });
  }
  // // 蛋奶速食
  // outcustard: Array<Pro>;
  getOutcustard (success: Function) {
    this.http.get('/api/outcustard').subscribe((data) => {
      success && success(data);
    });
  }
  // // 全球代购
  // outglobal: Array<Pro>;
  getOutglobal (success: Function) {
    this.http.get('/api/outglobal').subscribe((data) => {
      success && success(data);
    });
  }
  // 星期五 friday
  getfriday (success: Function) {
    this.http.get('/api/friday').subscribe((data) => {
      success && success(data);
    });
  }
  // 接收购物车
  // getcarts (success: Function) {
  //   this.http.get('/apl/carts').subscribe((data) => {
  //     success && success(data);
  // }
  getcarts (success: Function) {
    this.http.get('/apl/carts').subscribe((data) => {
      success && success(data);
    });
  }
  // 同城
  getTong (success: Function) {
    this.http.get('/api/tongc').subscribe((data) => {
      success && success(data);
    });
  }
}
